package com.rongc.client.freight.base.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;

import com.rongc.client.freight.R;
import com.rongc.client.freight.base.model.OrderDic;


/**
 * Created by Bruce on 2017/2/6.
 */
public class PayView extends LinearLayout {
    CheckBox mCbWX;
    CheckBox mCbAlipay;
    String type;
    public PayView(Context context) {
        this(context, null);
    }

    public PayView(Context context, AttributeSet attrs) {
        super(context, attrs);
        setOrientation(VERTICAL);
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.include_pay, this, true);
        mCbWX = (CheckBox) v.findViewById(R.id.cb_pay_wx);
        mCbAlipay = (CheckBox) v.findViewById(R.id.cb_pay_alipay);

        mCbWX.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    mCbAlipay.setChecked(false);
                    type = OrderDic.OrderType.Order_WX;
                }else{
                    type = "";
                }
            }
        });

        mCbAlipay.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    mCbWX.setChecked(false);
                    type = OrderDic.OrderType.Order_ALI;
                }else{
                    type = "";
                }
            }
        });
    }

    public String getType(){
        return type;
    }

    public void setEnabled(boolean enable){
        super.setEnabled(enable);
        mCbWX.setEnabled(enable);
        mCbAlipay.setEnabled(enable);
    }
}
